<style scoped>
	.c-panel{margin: 0px; padding: 0px 20px;}
</style>

<template>
	<el-dialog
		v-if="m"
		:title="'投诉处理'"
		:visible.sync="isShow"
		width="400px"
		top="25vh"
		:append-to-body="true"
		:destroy-on-close="true"
		:close-on-click-modal="false"
		custom-class="full-dialog"
		>
		<div class="vue-box">
			<div class="c-panel">
				<!-- 参数栏 -->
				<br>
				<el-form size="mini">
					<el-form-item label="投诉编号：">
						<el-input v-model="m.complainId" disabled></el-input>
					</el-form-item>
					<el-form-item label="投诉人：">
						<el-input v-model="m.uname"></el-input>
					</el-form-item>
					<el-form-item label="处理结果：">
						<el-input v-model="m.describe"></el-input>
					</el-form-item>
                   
					<!-- <el-form-item label="状态：">
						<el-radio-group v-model="m.status">
							<el-radio :label="1">正常</el-radio>
							<el-radio :label="2">禁用</el-radio>
						</el-radio-group>
					</el-form-item> -->
				</el-form>
			</div>
		</div>
		<span slot="footer" class="dialog-footer">
			<el-button size="small" @click="isShow = false">取 消</el-button>
			<el-button size="small" type="primary" @click="ok()">确 定</el-button>
		</span>
	</el-dialog>
</template>

<script>
	import mockDataList from './mock-data-list.js';
	export default {
		data() {
			return {
				isShow: false,
				id: 0,
				m: null
			}
		},
		methods: {
			// 打开 
			open: function(id) {
				// this.id = id;
                // alert("id:"+id);
				this.isShow = true;
				if(id != 0){
            this.sa.ajax(
                    '/e-administrator/complain/getComplainById',
                        {
                        complainId:id,	
                        }, 
                    function(res){
                    // alert("根据id获取成功:"+res.data);
                    this.m=res.data;
                        // this.propertyList = res.data;	// 数据
                        // this.dataCount = res.dataCount;	// 分页
                    }.bind(this),
					{type:'get'},
					);
				}
			},
			// 表单验证  
			submit_check: function() {
				// var m = this.m;
				// var sa = this.sa;
				// if(sa.isNull(m.name)) {
				// 	return sa.error('请输入名称');
				// }
				// if(sa.isNull(m.icon)) {
				// 	return sa.error('请输入图标');
				// }
				return 'ok';
			},
			// 提交 
			ok: function() {
				// 表单验证 
				if(this.submit_check() != 'ok') {
					return;
				}
				// 开始修改
				let self = this;
               if(self.m.complainId!=0){
                    // alert("hhhh:"+self.m.complainId);
                       this.sa.ajax(
					'/e-administrator/complain/updComplainById',
					{
					complainId:self.m.complainId,
                    uname:self.m.uname,
                    describe:self.m.describe,
                    state:1,
					}, 
					function(res){
					if(res){
                       self.sa.ok('处理成功', function() {
                        self.$parent.f5();	// 父视图刷新   
                        self.isShow = false;
                        // this.propertyList = res.data;	// 数据
                        // this.dataCount = res.dataCount;	// 分页
					
                    }.bind(this));
					}
					
				},
                {type:'put'},
				
            );
               }
            }, 
			// 创建一个空的model 
			create_m: function() {
				return {
					id: 0, 
					name: '', 
					icon: '',
					avatar: 'http://color-test.oss-cn-qingdao.aliyuncs.com/dyc/img/2020/01/19/15794196587511189314194.png', 
					money: 99.99,
					status: 1,
					create_time: new Date()
				}
			},
			// 遍历判断， 获取模拟数据  
			getMockData: function(id) {
				var data = null;
				// 遍历判断 
				mockDataList.data.forEach(function(item) {
					if(item.id == id) {
						data = item;
					}
				})
				// 创建模拟数据 
				var mockData = {
					code: 200,
					msg: 'ok',
					data: data
				}
				return mockData;
			}
		},
		created: function(){
			
		}
	}
</script>
